#!/bin/bash

#./monkeyTestOnAllAndroid.sh /WorkspaceAndroid/MyApp/bin/MyApp.apk com.me.myapp/com.me.myapp.MyActivity 1000

if [ -z "$1" ]; then 
        echo " "
        echo " "
	echo " usage: $0 apkPath package <event-count>"
    echo " "
	echo " 		apkPath : path ok apk file" 
	echo "		package : package in manifest"
        echo " "
        echo " "
	exit
fi

apkPath=$1
package=$2
num_event=$3

##############
# Function
#############

function monkeyTest {
	echo "Starting monkey test on $1"
	$ANDROID_HOME/tools/adb -s $1 install -r $2
# $ANDROID_HOME/tools/adb -s $1 shell am start -n $3
    echo "$ANDROID_HOME/tools/adb -s $1 shell monkey -p $3 -v -v -v $4"
	$ANDROID_HOME/tools/adb -s $1 shell monkey -p $3 -v -v -v $4
}  

##############
# For each devices
#############

for i in `$ANDROID_HOME/tools/adb devices | sed "/List of devices attached/d" | sed "s/device//g"`;do 
	monkeyTest $i $apkPath $package $num_event &
done

